<?php
include "../../../lib/list.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/insert.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/table.blue.sorter.css" type="text/css" media="print, projection, screen"></link>

<script type="text/javascript" src="../../../js/list.js"></script>
<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>

<script type="text/javascript">
function insert(){
	document.detail.mode.value 	 = 'defect';
	document.detail.target		 = 'right';
	document.detail.action		 = 'query.php';
	document.detail.method		 = 'post';
	document.detail.submit();
}

function search(){
	document.search.s_no.value = document.detail.s_no.value;
	document.search.target = 's_iframe';
	document.search.action = 's_iframe.php';
	document.search.method = 'post';
	document.search.submit();
}

function deleteRow(obj){
 $(obj).parent().remove();
}

function product(ino, iname, iprice, ibarcode){
	 var chk_no	= 	document.getElementsByName('p_no[]');
	 for(i=0;i<chk_no.length;i++){
			if(chk_no[i].value==ino){
				alert('이미 입력하신 제품입니다.');
				 return;
				}
		}
		
	var html = "<tr><input type='hidden' name='p_no[]' value='"+ino+"'/>"
				+"<td>"+ibarcode+"</td>"
				+"<td>"+iname+"</td>"
				+"<td>"+iprice+"￥</td>"	
				+"<td style='width:50px;'>"
				+"<input type='text' name='count[]' value='1' size='3' onkeyup='this.value=this.value.replace(/[^0-9]/g,'')' class='default' style='text-align:right'></input>개</td>"
				+"<td onclick='deleteRow(this);' style='cursor:pointer;text-align:center'>삭제</td></tr>";
				
	$("#tablesorter").prepend(html);
}

var i;
function show_middlecategory(res){
    $("select[name='middlecategory']").eq(i).html(res);
}
function show_smallcategory(res){
    $("select[name='smallcategory']").eq(i).html(res);
}

$(function(){
    $("select[name='sg_no']").change(function(){
	    var sg_no = $("select[name='sg_no']").attr('value');
	    $.get('../../../lib/select.php?sg_no='+sg_no,function(res){
	        $("select[name='s_no']").html(res);
	    });
	});  

	$("select[name='s_no']").change(function(){
        $("#tablesorter tbody tr").remove();
        search();
		});
	
    $("select[name='bigcategory']").change(function(){
        i = $("select[name='bigcategory']").index(this); 
        var b_no = $("select[name='bigcategory']").eq(i).attr('value');
        $.get('../../../lib/category.php?b_no='+b_no,show_middlecategory);
        $.get('../../../lib/category.php?m_no=-1',show_smallcategory);
    });
    
    $("select[name='middlecategory']").change(function(){
        i = $("select[name='middlecategory']").index(this); 
        var m_no = $("select[name='middlecategory']").eq(i).attr('value');
        $.get('../../../lib/category.php?m_no='+m_no,show_smallcategory);
    }); 
}
);

</script>
</head>
<body>
	<div style="width: 1024px; padding: 10px;">
		<div
			style="border-bottom: 1px solid #e8e8e8; text-align: left; font-size: 12px; margin-bottom: 12px; color: #9a9a9a">:::
			재고 관리&nbsp;⇒&nbsp;결함품 입력</div>
		<form name="search" method="post" action="iframe.php" enctype=multipart/form-data>
			<div id=search>
			<div style="height:180px; float:right;width:300px;border-left:2px solid #e8e8e8;">
			<iframe src="s_iframe.php" id="s_iframe"
				name="s_iframe" frameborder="0" width="300px" height="180px;"></iframe>
			</div>
			
					<input name="mode" value="search" type="hidden" />
					<input name="s_no" value="" type="hidden" />
					
		<ul>
			<li class="lable">Barcode</li>
			<li class="value"><input type="text" size="20" name="barcode"  onkeyup="number_check(this)"/>
			</li>
			<li class="lable">대분류</li>
			<li class="value">
			<select name="bigcategory" style="width:155px; margin-left:2px">
			<option value="-1">:: 대분류 선택 ::</option>
			<?
			$qry = "SELECT * FROM uatp_biggestcategory";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
		</ul>
		<ul>
			<li class="lable">상품명</li>
			<li class="value"><input type="text" size="20" name="name" />
			</li>
			<li class="lable">중분류</li>
			<li class="value">			
			<select name="middlecategory" style="width:155px; margin-left:2px">
			<option value="">:: 중분류 선택 ::</option>
			</select>
			</li>
		</ul>
		<ul>
			<li class="lable">상품명(가나)</li>
			<li class="value"><input type="text" size="20" name="namegana" />
			</li>
			<li class="lable">소분류</li>
			<li class="value">			
			<select name="smallcategory" style="width:155px; margin-left:2px">
			<option value="">:: 소분류 선택 ::</option>
			</select>
			</li>
		</ul>
		<ul>
		
			<li class="lable">구매처</li>
			<li class="value">
			<select name="buyer" style="width:155px; margin-left:2px">
			<option value="">:: 전부 검색 ::</option>
			<?
			$qry = "SELECT * FROM uatp_buyer";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
		
			<li class="lable">소속부문</li>
			<li class="value">
			<select name="bumun" style="width:155px; margin-left:2px">
			<option value="">:: 전부 검색 ::</option>
			<?
			$qry = "SELECT * FROM uatp_bumun";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
		</ul>
		<ul>
		<li class="bottom">
		<a href="javascript:search()" class="button white small">&nbsp;검색하기&nbsp;</a>
		</li>
		</ul>		
	</div>
	</form>
			<form name="detail" method="post" action="query.php" enctype=multipart/form-data>
			<input name="mode" value="insert" type="hidden"/>
				
			<table cellspacing="1" id="tablesorter" class="tablesorter" style="width:600px;float:right;">
			
				<thead>
					<tr>
						<th style="width:80px;">barcode</th>
						<th>상품 명</th>
						<th style="width:80px;">가격</th>
						<th style="width:50px;">수량</th>
						<th style="width:25px;"></th>
					</tr>
					</thead>
					<tbody>
					</tbody>
					</table>	
						
						<div style="width:400px;float:left;">		
						<table class="entry fixed H_15px" summary="재고-입력상단부">
						<tr>
								<th style="width:20%">관리자</th>
								<td><?=$_SESSION['IS_NAME']?></td>
						</tr>
						  <tr>
						      <th style="width:20%">점포그룹</th>
						      <td>
						<select name='sg_no' class="default" style="width:200px;">
						<option value="-3">:: 점포그룹 선택 ::</option>
						<?
						$qry = "SELECT * FROM uatp_shopgroup order by no DESC";
						$query = DBquery($qry);
						while($list = mysql_fetch_array($query)){
							?>
						<option value="<?=$list['no']?>"><?=$list['name']?></option>
						<?
						}
						mysql_close();
						?>
						</select>
					</td>
						</tr>
						<tr>
						      <th style="width:20%">점포명</th>
						      <td>
						<select name='s_no' class="default" style="width:200px;">
							<option value="">:: 점포 선택 ::</option>
						</select>
						</td>
						</tr>
						<tr>
								<th style="width:20%">내용</th>
								<td><input type='text' name='note' value="" class="default" style="width:95%;"/></td>
						</tr>
						</table>
					
							
							<div style="padding-top:15px;width:400px;float:right;">
							<center><a href="javascript:insert()" class="button blue small" style="width:150px;">&nbsp;입력하기&nbsp;</a></center>
							</div>
						</div>		
			</form>
	</div>
</body>
</html>